package com.mvp.lt.airlineview.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.mvp.lt.airlineview.R;

import java.util.ArrayList;
import java.util.List;

import com.mvp.lt.airlineview.DemoModel;
import com.mvp.lt.airlineview.adapter.UIDemoAdapter;

public class TestActivity extends AppCompatActivity {
    private UIDemoAdapter adapter;
    private List<DemoModel> data = new ArrayList<>();
    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        initData();

    }

    public void initData() {
        data.add(new DemoModel("RecyclerView实现TextView的画廊效果", TextRecyclerViewActivity.class, 0));
        data.add(new DemoModel("两个viewpager联动", ViewPagerActivity.class, 0));
        data.add(new DemoModel("RecyclerView实现Gallery画廊效果", RecyclerviewCardGalleryActivity.class, 0));
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        adapter = new UIDemoAdapter(data);
        recyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                DemoModel demoModel = (DemoModel) adapter.getItem(position);
                if (demoModel != null) {
                    startActivity(new Intent(TestActivity.this, demoModel.getClazz()));
                }
            }
        });

    }
}
